Repository navigation
fix(proc): a kill before the child's setsid reaches the child - #18
Merged
Merged
Conversation
The child makes its process group with setsid after the fork, while run publishes the pgid and can kill the group at once. A cancel flag set before the call sends that kill before the child has run, the kill finds no group, and the child runs its script: the call waits until it exits, and what it started outlives the call. A stopGroup on the pgid as soon as it is published misses the same way. Each test makes a hundred calls to a script that starts a background sleep and sleeps two seconds, and checks that each returns within a second and leaves nothing alive; the stopGroup one runs on one CPU, where the stop comes first nearly every time. Both fail until a group kill reaches a child that has not made its group.
The child makes its process group with setsid once it runs, but run publishes the pgid and can signal the group straight after the fork. A cancel or a timeout that came first, or a stopGroup on the pgid just published, found no group and missed: "a set cancel flag kills the child" waited out its sleep 30, and a handler that stops the group and exits left the child running. A group signal that finds no group now goes to the child itself, which starts nothing before it execs, and then to the group again in case the child made it in between. Once the group exists nothing changes, and stopGroup stays safe in a signal handler. Waiting for the child to make its group or to exec would hold run before it can honor a cancel or a deadline, and a setpgid in the parent as well would make the child's setsid fail.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
proc.runcould miss a child that had not yet calledsetsid. The child makes its process group withsetsidafter the fork, butrunpublishes the pgid and can signal the group at once. A cancel flag that was already set, a timeout with no grace, or astopGroupon a just-published pgid therefore sent SIGKILL to a group that did not exist yet, so the child ran to the end and what it started outlived the call.A group signal that finds no group now goes to the child itself, which has started nothing before it execs, and then to the group again in case the child made it in between. The change is in the one private helper that cancel, timeout and
stopGroupshare, and it still uses only system calls, sostopGroupstays safe inside a signal handler.Two new tests cancel, or call
stopGroup, as soon as the child is forked, a hundred times each. Both fail on main natively and under QEMU and pass with the fix. "a set cancel flag kills the child" now takes milliseconds instead of 30 s.The tools matrix (eb-keep-logs, eb-local, eb-staged-rebuild, eessi-arch-guard) gives the same results as on main.